#ifndef __DX_HELPER_H__
#define __DX_HELPER_H__


#ifndef __DX_ERR_H__
#include <DxErr.h>
#define __DX_ERR_H__
#endif

#ifndef __SSTREAM_H__
#include <sstream>
#define __SSTREAM_H__
#endif


#if defined(DEBUG) | defined(_DEBUG)
	#ifndef HR
	#define HR(x)                                                                                  \
	{                                                                                              \
		HRESULT result = x;                                                                        \
		if (FAILED(x))                                                                             \
		{                                                                                          \
			std::ostringstream outs;                                                               \
		    outs << "FILE: " << __FILE__ << "\nLine: " << __LINE__;                                \
			MessageBox(NULL, TEXT(outs.str().c_str()), TEXT("TITLE: Error!"), MB_OK);              \
		}                                                                                          \
	}
	#endif
#else
	#ifndef HR
	#define HR(x) x
	#endif
#endif


#define ReleaseCOM(x)                                                                              \
{                                                                                                  \
	if (x != NULL)                                                                                 \
    {                                                                                              \
	    x -> Release();                                                                            \
		x = NULL;                                                                                  \
    }                                                                                              \
}


#define RELEASE(x)                                                                                 \
{                                                                                                  \
	if (x != NULL)                                                                                 \
	{                                                                                              \
		delete x;                                                                                  \
		x = NULL;                                                                                  \
	}                                                                                              \
}


#define RELEASEARRAY(x)                                                                            \
{                                                                                                  \
	if (x != NULL)                                                                                 \
	{                                                                                              \
		delete []x;                                                                                \
		x = NULL;                                                                                  \
	}                                                                                              \
}


#endif